ranks = [1, 2, 3, 4]
names = ['Mike', 'Ellie', 'Rohan', 'Fatma']
bikes = ['红', '紫', '蓝', '绿']

all_kinds = [(rank, name, bike) for rank in ranks for name in names for bike in bikes]
# print(len(all_kinds))  4*4*4=64种

impossible_kinds =[]
for kind in all_kinds:
    # Ellie骑紫色的车，Rohan没有骑绿色的车
    if (kind[1] == 'Ellie' and kind[2] != '紫') \
            or (kind[1] == 'Mike' and kind[2] == '紫') or (kind[1] == 'Rohan' and kind[2] == '紫') or (kind[1] == 'Fatma' and kind[2] == '紫')\
            or (kind[1] == 'Rohan' and kind[2] == '绿'):
        impossible_kinds.append(kind)
        continue

    # Mike和Ellie不是第一，也不是最后。
    if (kind[1] == 'Mike' and (kind[0] == 1 or kind[0] == 4)) or (kind[1] == 'Ellie' and (kind[0] == 1 or kind[0] == 4)):
        impossible_kinds.append(kind)
        continue

    # 骑蓝色车的人领先于Fatma
    if (kind[2] == '蓝' and kind[0] == 4) or (kind[2] == '蓝' and kind[1] == 'Fatma') or (kind[1] == 'Fatma' and kind[0] != 4) or (kind[1] == 'Rohan' and kind[0] != 1):
        impossible_kinds.append(kind)
        continue

    # 骑绿色车的人领先骑紫色车的人
    if (kind[2] == '绿' and kind[0] != 2) or (kind[2] == '紫' and kind[0] != 3) or (kind[1] == 'Mike' and kind[0] == 3):
        impossible_kinds.append(kind)
        continue

possible_kinds = [kind for kind in all_kinds if kind not in impossible_kinds]

for kind in possible_kinds:
    if kind[0] == 2:
        print(f'第二名是{kind[1]}')















